<?php
/**
 * Created by PhpStorm.
 * User: ownfi
 * Date: 2017-04-03
 * Time: 1:04
 */

namespace App\Services\Impl;


use App\Common\Constant\Params;
use App\Services\IMerchantService;
use Illuminate\Support\Collection;

class MerchantServiceImpl implements IMerchantService
{

    public function transformMasterServiceType(array $master_service_type)
    {
        return Collection::make(array_keys(Params::$MERCHANT_SERVICE_TYPE))->filter(function($item,$key) use ($master_service_type){
            switch ($item){
                case Params::MERCHANT_SERVICE_TYPE_DELIVERY_INSTALL:
                    return in_array(Params::SERVICE_TYPE_DELIVERY,$master_service_type) && in_array(Params::SERVICE_TYPE_INSTALL,$master_service_type);
                case Params::MERCHANT_SERVICE_TYPE_INSTALL:
                    return in_array(Params::SERVICE_TYPE_INSTALL,$master_service_type);
                case Params::MERCHANT_SERVICE_TYPE_REPAIR:
                    return in_array(Params::SERVICE_TYPE_REPAIR,$master_service_type);
                case Params::MERCHANT_SERVICE_TYPE_DELIVERY:
                    return in_array(Params::SERVICE_TYPE_DELIVERY,$master_service_type);
                case Params::MERCHANT_SERVICE_TYPE_PACK_RETURN:
                    return in_array(Params::SERVICE_TYPE_DELIVERY,$master_service_type);
                default:
                    return false;
            }
        })->toArray();
    }

}